﻿using System;

namespace Validate.Net
{
    /// <summary>
    /// 邮政编码验证
    /// </summary>
    public class ValidateZipCodeAttribute : ValidateRegularAttribute
    {
        private static string regularStr = @"^[0-9]{6}$";

        public ValidateZipCodeAttribute() : base(regularStr)
        { }

        /// <summary>
        /// 邮政编码验证
        /// </summary>
        /// <param name="value"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public override bool Validate(object value, out string msg)
        {
            if (base.Validate(value, out msg))
                return true;
            else
            {
                msg = "邮政编码格式校验失败";
                return false;
            }
        }
    }
}
